home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qapplication.h.z / qapplication.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  5.7 KB  |  221 lines

  1. /****************************************************************************
  2. ** $Id: qapplication.h,v 2.28 1998/07/03 00:09:30 hanord Exp $
  3. **
  4. ** Definition of QApplication class
  5. **
  6. ** Created : 931107
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QAPPLICATION_H
  25. #define QAPPLICATION_H
  26.  
  27. #ifndef QT_H
  28. #include "qwidget.h"
  29. #endif // QT_H
  30.  
  31.  
  32. #if defined(TrueColor)
  33. // X11/X.h #defines TrueColor, so it can't be used in any class or enum
  34. #error "TrueColor already #defined by X11/X.h. Include X11/X.h after qapplication.h"
  35. #endif
  36.  
  37. extern QApplication *qApp;            // global application object
  38.  
  39.  
  40. class QApplication : public QObject        // application class
  41. {
  42.     Q_OBJECT
  43. public:
  44.     QApplication( int &argc, char **argv );
  45. #if defined(_WS_X11_)
  46.     QApplication( Display* dpy );
  47. #endif
  48.     virtual ~QApplication();
  49.  
  50.     int            argc()    const;
  51.     char      **argv()    const;
  52.  
  53.     static GUIStyle style();
  54.     static void        setStyle( GUIStyle );
  55.  
  56. #if 1    /* OBSOLETE */
  57.     enum ColorMode { NormalColors, CustomColors };
  58.     static ColorMode colorMode();
  59.     static void      setColorMode( QApplication::ColorMode );
  60. #endif
  61.  
  62.     enum ColorSpec { NormalColor=0, CustomColor=1, PrivateColor=4,
  63.              ManyColor=4, TrueColor=4 };
  64.     static int         colorSpec();
  65.     static void      setColorSpec( int );
  66.  
  67.     static QCursor  *overrideCursor();
  68.     static void         setOverrideCursor( const QCursor &, bool replace=FALSE );
  69.     static void         restoreOverrideCursor();
  70.  
  71.     static bool         hasGlobalMouseTracking();
  72.     static void         setGlobalMouseTracking( bool enable );
  73.  
  74.     static QPalette *palette();
  75.     static void         setPalette( const QPalette &,bool updateAllWidgets=FALSE);
  76.  
  77.     static QFont    *font();
  78.     static void         setFont( const QFont &, bool updateAllWidgets=FALSE );
  79.     static QFontMetrics fontMetrics();
  80.  
  81.     QWidget        *mainWidget()  const;
  82.     void         setMainWidget( QWidget * );
  83.  
  84.     static QWidgetList *allWidgets();
  85.     static QWidgetList *topLevelWidgets();
  86.     static QWidget  *desktop();
  87.     static QWidget  *activePopupWidget();
  88.     static QWidget  *activeModalWidget();
  89.     static QClipboard *clipboard();
  90.     QWidget        *focusWidget() const;
  91.  
  92.     static QWidget  *widgetAt( int x, int y, bool child=FALSE );
  93.     static QWidget  *widgetAt( const QPoint &, bool child=FALSE );
  94.  
  95.     int             exec();
  96.     void         processEvents();
  97.     void         processEvents( int maxtime );
  98.     void         processOneEvent();
  99.     int             enter_loop();
  100.     void         exit_loop();
  101.     static void         exit( int retcode=0 );
  102.  
  103.     static bool         sendEvent( QObject *receiver, QEvent *event )
  104.     { return qApp->notify( receiver, event ); }
  105.     static void         postEvent( QObject *receiver, QEvent *event );
  106.     static void         sendPostedEvents( QObject *receiver, int event_type );
  107.  
  108.     virtual bool     notify( QObject *, QEvent * );
  109.  
  110.     static bool         startingUp();
  111.     static bool         closingDown();
  112.  
  113.     static void         flushX();
  114.     static void         syncX();
  115.  
  116.     static void         beep();
  117.  
  118.     static void      setWinStyleHighlightColor( const QColor & );
  119.     static const QColor&   winStyleHighlightColor();
  120.  
  121.     static void        setDoubleClickInterval( int );
  122.     static int      doubleClickInterval();
  123.  
  124. #if defined(_WS_MAC_)
  125.     virtual bool     macEventFilter( MSG * );
  126. #elif defined(_WS_WIN_)
  127.     virtual bool     winEventFilter( MSG * );
  128. #elif defined(_WS_PM_)
  129.     virtual bool     pmEventFilter( QMSG * );
  130. #elif defined(_WS_X11_)
  131.     virtual bool     x11EventFilter( XEvent * );
  132.     int              x11ProcessEvent( XEvent* );
  133. #endif
  134.  
  135. #if defined(_WS_WIN_)
  136.     void         winFocus( QWidget *, bool );
  137. #endif
  138.  
  139. signals:
  140.     void         lastWindowClosed();
  141.  
  142. public slots:
  143.     void         quit();
  144.  
  145. private:
  146.     bool         processNextEvent( bool );
  147.     void         initialize( int, char ** );
  148.  
  149.     int             app_argc;
  150.     char       **app_argv;
  151.     bool         quit_now;
  152.     int             quit_code;
  153.     static GUIStyle  app_style;
  154.     static int         app_cspec;
  155.     static QPalette *app_pal;
  156.     static QFont    *app_font;
  157.     static QCursor  *app_cursor;
  158.     static int         app_tracking;
  159.     static bool         is_app_running;
  160.     static bool         is_app_closing;
  161.     static int         loop_level;
  162.     static QWidget  *main_widget;
  163.     static QWidget  *focus_widget;
  164.  
  165.     friend class QWidget;
  166.     friend class QETWidget;
  167.  
  168. private:    // Disabled copy constructor and operator=
  169.     QApplication( const QApplication & );
  170.     QApplication &operator=( const QApplication & );
  171. };
  172.  
  173.  
  174. inline int QApplication::argc() const
  175. {
  176.     return app_argc;
  177. }
  178.  
  179. inline char **QApplication::argv() const
  180. {
  181.     return app_argv;
  182. }
  183.  
  184. inline GUIStyle QApplication::style()
  185. {
  186.     return app_style;
  187. }
  188.  
  189. inline QCursor *QApplication::overrideCursor()
  190. {
  191.     return app_cursor;
  192. }
  193.  
  194. inline bool QApplication::hasGlobalMouseTracking()
  195. {
  196.     return app_tracking > 0;
  197. }
  198.  
  199. inline QFont *QApplication::font()
  200. {
  201.     return app_font;
  202. }
  203.  
  204. inline QWidget *QApplication::mainWidget() const
  205. {
  206.     return main_widget;
  207. }
  208.  
  209. inline QWidget *QApplication::focusWidget() const
  210. {
  211.     return focus_widget;
  212. }
  213.  
  214. inline QWidget *QApplication::widgetAt( const QPoint &p, bool child )
  215. {
  216.     return widgetAt( p.x(), p.y(), child );
  217. }
  218.  
  219.  
  220. #endif // QAPPLICATION_H
  221.